import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    lists: [
      { name: "马云", price: 200 },
      { name: "马化腾", price: 150 },
      { name: "马冬梅", price: 20 },
      { name: "马蓉", price: 10 }
    ]
  },
  getters:{
    num:(state)=>{
      var num = state.lists.map(
        item=>{
          return {
            name:"**"+ item.name +"**",
            price:item.price/2
          }
        }
      )
      return num
    }
  },

  mutations: {
    depreciate(state){
        state.lists.forEach(list=>{
        list.price-=1
      })
    }
  },
  actions: {

  }
})
